import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalLogoutPage(Base):
    """
    账户注销弹窗
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 注销提示标题
        self.logout_tip_title_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_title"))

        # 注销描述语(是否注销该账户)
        self.logout_list_content_one_text = (By.XPATH, Personal.logout_tip_text.format(""))

        # 注销描述语(注销后....)
        self.logout_list_content_two_text = (By.XPATH, Personal.logout_tip_text.format(""))

        # 删除按钮
        self.logout_delete_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_sure"))

        # 取消按钮
        self.logout_cancel_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_cancel"))

    def get_tip_title(self):
        """
        获得注销页面标题

        :return: 获取元素
        """
        return self.find_element_o(self.logout_tip_title_text)

    def get_list_content_one(self, index=1):
        """
        获得注销页面提示语1
        index 默认取1
        :return: 获取元素
        """
        self.logout_list_content_one_text = (By.XPATH, Personal.logout_tip_text.format(index))
        return self.find_element_o(self.logout_list_content_one_text)

    def get_list_content_two(self, index=2):
        """
        获得注销页面提示语2
        index 默认取2
        :return: 获取元素
        """
        self.logout_list_content_two_text = (By.XPATH, Personal.logout_tip_text.format(index))
        return self.find_element_o(self.logout_list_content_two_text)

    def click_delete(self):
        """
        点击注销确认按钮

        :return: None
        """
        self.click_element(self.logout_delete_btn)

    def click_cancel(self):
        """
        点击注销确认按钮

        :return: None
        """
        self.click_element(self.logout_cancel_btn)

    def is_display_personal_logout(self):
        """
        是否进入注销界面

        :return: bool
        """
        return self.is_display(self.logout_tip_title_text)

    def is_toast_personal_logout(self):
        """
        是否密码修改成功

        :return: bool
        """
        return self.is_toast_exist(text="账户已注销")


